package com.sjc.transfrom

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object RDD_32_randomSplit {
    
    def main(args: Array[String]): Unit = {
        
        val sparkConf = new SparkConf().setAppName("RDD_31_pipe").setMaster("local")
        val sc = new SparkContext(sparkConf)
        
        val dataRDD: RDD[Int] = sc.parallelize(1 to 10)
        
        // 按照百分比随机数据到多个RDD
        val splitsRDD: Array[RDD[Int]] = dataRDD.randomSplit(Array(0.6, 0.4))
        
        splitsRDD.foreach(subRDD => {
            subRDD.foreach(x => print(x + "\t"))
            println()
        })
        
    }
}
